package org.wanho.manager.mapper;

import org.wanho.manager.entity.Role;
import org.wanho.manager.entity.User;
import org.wanho.util.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Author：汤小洋
 * Date：2023-04-23 14:32
 * Description：<描述>
 */
public class UserMapper implements RowMapper<User> {
    @Override
    public User mapRow(ResultSet rs) throws SQLException {
        User u = new User();
        u.setId(rs.getInt("id"));
        u.setLoginName(rs.getString("login_name"));
        u.setPassword(rs.getString("password"));

        Role role = new Role();
        role.setId(rs.getInt("rid"));
        role.setRoleName(rs.getString("role_name"));
        u.setRole(role);
        return u;
    }
}
